
package org.apache.solr.update;

import org.apache.lucene.index.DirectoryReader;
import org.apache.solr.request.SolrQueryRequest;

/**
 * A merge indexes command encapsulated in an object.
 *
 * @since solr 1.4
 */
public class MergeIndexesCommand extends UpdateCommand {

    public DirectoryReader[] readers;

    public MergeIndexesCommand(DirectoryReader[] readers, SolrQueryRequest req) {
        super(req);
        this.readers = readers;
    }

    @Override
    public String name() {
        return "mergeIndexes";
    }

    @Override
    public String toString() {

        StringBuilder sb = new StringBuilder(super.toString());
        if (readers != null && readers.length > 0) {
            sb.append(readers[0].directory());
            for (int i = 1; i < readers.length; i++) {
                sb.append(",").append(readers[i].directory());
            }
        }
        sb.append('}');

        return sb.toString();
    }
}
